package top.hymsk.ecommerce.pojo.DO;

import lombok.Data;
import top.hymsk.ecommerce.pojo.DTO.PlaceProductDTO;
import top.hymsk.ecommerce.utils.DecimalUtils;

import java.util.List;

/**
 * @author 花于陌上开
 */
@Data
public class OrderGoodsListDO {
    List<PlaceProductDTO> orderGoodList;
    Double amount=0.;

    public OrderGoodsListDO(List<PlaceProductDTO> placeProductList,List<Integer> productNumberList){
        for (int i=0;i<productNumberList.size();i++) {
            placeProductList.get(i).setNumber(productNumberList.get(i));
            double actualPrice=DecimalUtils.round(placeProductList.get(i).getNumber()*placeProductList.get(i).getPrice());
            amount+=actualPrice;
            placeProductList.get(i).setActualPrice(actualPrice);
        }
        orderGoodList=placeProductList;
        amount=DecimalUtils.round(amount);
    }
}
